package file;

import java.io.File;
import java.util.HashMap;

public class Demo5 {
    public static void main(String[] args) {
        File f = new File("Day12");
        HashMap<String, Integer> map = new HashMap<>();
        getNum(map, f);
        System.out.println(map);
    }

    private static void getNum(HashMap<String, Integer> map, File f) {
        File[] files = f.listFiles();
        for (File file : files) {
            if (file.isFile()) {
                String name = file.getName();
                String[] split = name.split("\\.");
                //a.txt
                String s = split[split.length - 1];
                //判断
                map.put(s,map.containsKey(s)? map.get(s)+1:1);
            }else{
                getNum(map,file);
            }
        }
    }
}
